import 'package:flutter/material.dart';
import '../model/post_data.dart';

class ListViewDemo extends StatelessWidget {
  Widget _itemViewBuilder(BuildContext context, int index) {
    return Container(
      color: Colors.white,
      margin: EdgeInsets.all(8.0),
      child: Column(
        children: <Widget>[
          Image.network(posts[index].imageUrl, scale: 1.0),
          SizedBox(height: 8.0),
          Text(
            posts[index].title,
            style: Theme.of(context).textTheme.titleLarge,
          ),
          Text(
            posts[index].author,
            style: Theme.of(context).textTheme.titleMedium,
          ),
          SizedBox(height: 8.0),
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return ListView.builder(
      itemBuilder: _itemViewBuilder,
      itemCount: posts.length,
    );
  }
}
